<template>
	<view class="content">
		<!-- #ifdef H5 || APP-PLUS -->
		<view class="message-title">
			<commonTitle title="提现记录"></commonTitle>
		</view>
		<!-- #endif -->
		<!-- <view class="tip">说明：每月22日统一发放上月邀请奖励</view> -->
		<view class="list-scroll-content">
			<scroll-view class="my-share-detail" v-if="list.length>0" scroll-y="true"  @scrolltolower="loadMore">
					<view class="list-item" v-for="(item,index) in list" :key="index">
						<view class="item-left">
							<view class="item-title">支付宝:{{item.zfbNo}}</view>
							<view class="item-time">{{getTime(item.createTime.time)}}</view>
						</view>
						<view class="item-captial-num">-{{item.amount}}</view>
					</view>
			</scroll-view>
			<view class="nodata" v-else>
				<image src="../../static/common/nodata-sub.png" class="nodataimg"></image>
			</view>
		</view>
		
	</view>
</template>

<script>
	import commonTitle from'../../components/sub-titile/title.vue'
	const util = require('../../util/util.js');
	export default{
		components:{
			commonTitle
		},
		data () {
			return {
				apptoken:"",
				pageIndex:1,
				nodata:false,
				list:[]
			}
		},
		onLoad() {
			this.apptoken = uni.getStorageSync("apptoken");
			this.getCashHistoryList();
		},
		methods: {
			getTime(t){
				return this.$CommonJS.getTime(t,1)
			},
			getCashHistoryList(type){
				const _this = this;
				uni.request({
					url:this.$API.URL + this.$API.TktixianDetail,
					data:{apptoken:this.apptoken,pageIndex:this.pageIndex},
					success(res) {
						console.log(res);
						if(res.data.success){
							const d = res.data.data;
							if(d.length<1 && _this.pageIndex !=1){
								_this.nodata = true;
								_this.$CommonJS.showToast("没有更多数据了");
							}else{
								if(type){
									//分页
									d.forEach(item=>{
										_this.list.push(item)
									})
								}else{
									_this.list = d;
								}
								_this.pageIndex++;
							}
							
						}else{
							_this.$CommonJS.showToast(res.data.msg)
						}
					}
				})
			},
			//防抖事件//商品分页
			loadMore: util.throttle(function(e) {
				if(!this.nodata){
					this.getCashHistoryList('loadMore')
				}
			}, 300),
		}
		
	}
</script>

<style scoped>
	@import url("cashHistory.css");
</style>
